
macro(add_component component_name)
    set( component_files )
    message(STATUS "add component: ${component_name}")
    if(${component_name} STREQUAL ${PROJECT_NAME} )
        add_files( ${INCLUDE_DIR} ${SOURCE_DIR} )
        detected_target_property()
        source_group(${PROJECT_NAME} FILES ${component_files} )
    elseif(${component_name} STREQUAL "unit_test")
        add_files( ${INCLUDE_DIR} ${SOURCE_DIR} )
        source_group(unit_test FILES ${component_files} )
    else()
        add_files( ${INCLUDE_DIR}/${component_name} ${SOURCE_DIR}/${component_name} )
        source_group(${PROJECT_NAME}\\${component_name} FILES ${component_files} )
    endif()
    list(APPEND PRODUCT_SOURCES_FILES ${component_files} )
endmacro()

macro(add_files hpppath__ cpppath__ )
    file(GLOB _current  ${hpppath__}/*.*)
    if(_current)
        list(APPEND component_files ${_current} )
    endif()
    file(GLOB _current  ${cpppath__}/*.*)
    if(_current)
        list(APPEND component_files ${_current} )
    endif()
endmacro()

macro(detected_target_property)
    if(NOT THIS_TARGET)
        foreach( _unit ${_current} )
            get_filename_component(_unit ${_unit} NAME)
            if(_unit STREQUAL "main.cpp")
                message(STATUS "detected executable")
                set(THIS_TARGET "executable")
            endif()
        endforeach()
    endif()
endmacro()
